﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Configuration
{
    public class Config
    {

        private static Double zInlet  =  0.02;
        private static Double zOutlet =  0.02;
        static TransFormationRadioConfig transformationRatio;
        static string phaseInfo;
        static string flowmeter;

        public static TransFormationRadioConfig TransFormationRadioConfig
        {
            get
            {
                if (transformationRatio == null)
                {
                    String config = InitConfig.getString("BaseInfo", "TransformationRatio", null);
                    transformationRatio = new TransFormationRadioConfig(config);
                    if (transformationRatio == null)
                    {
                        throw new ArgumentNullException("setupint file node TransformationRatio is null!");
                    }
                }
                return transformationRatio;
            }
        }

        
        public static  string PhaseInfo
        {
            get
            {
                if (phaseInfo == null)
                {
                    phaseInfo = InitConfig.getString("BaseInfo", "PhaseInfo",null);
                    if (phaseInfo == null)
                    {
                        throw new ArgumentNullException("setupint file node flowmeter is null!");
                    }
                }
                return phaseInfo;
            }
        }



        public static string Flowmeter
        {
            get
            {
                if (flowmeter == null)
                {
                    flowmeter = InitConfig.getString("BaseInfo", "Flowmeter",null);
                    if (flowmeter == null)
                    {
                        throw new ArgumentNullException("setupint file node flowmeter is null!");
                    }
                }
                return flowmeter;
            }
        }

        /// <summary>
        /// 默认入口摩擦系数
        /// </summary>
        public static Double kInlet = Double.NaN;
        public static Double KInlet
        {
            get
            {

                if (kInlet.Equals(Double.NaN))
                {
                    string str = InitConfig.getString("BaseInfo", "KInlet", "0.0005");
                    kInlet = Double.Parse(str);
                }

                return kInlet;
            }
        }

        /// <summary>
        /// 默认出口摩擦系数
        /// </summary>
        public static Double kOutlet = Double.NaN;
        public static Double KOutlet
        {
            get
            {
                if (kOutlet.Equals( Double.NaN))
                {
                    string str = InitConfig.getString("BaseInfo", "KOutlet", "0.0005");
                    kOutlet = Double.Parse(str);
                }

                return kOutlet;
            }
        }




        /// <summary>
        /// 进口取压高度
        /// </summary>
        public static double ZInlet
        {
            get
            {
                    if (zInlet.Equals(Double.NaN))
                    {
                        string str = InitConfig.getString("BaseInfo", "ZInlet", "0.02");
                        zInlet = Double.Parse(str);
                    }

                    return zInlet;
                }
        }

        /// <summary>
        /// 出口取压高度
        /// </summary>
        public static double ZOutlet
        {
             get
             {
                    if (zOutlet.Equals(Double.NaN))
                    {
                        string str = InitConfig.getString("BaseInfo", "ZOutlet", "0.02");
                        zOutlet = Double.Parse(str);
                    }
                    return zOutlet;
             }
        }


        public static String basePath = null;
        public static String BasePath
        {
            get
            {
                if (basePath == null)
                {
                    basePath = InitConfig.getString("BaseInfo", "BasePath", @"D:\PumpExperiment");
                    basePath = basePath.Replace("||", "\\");
                }
                return basePath;
            }
        }

        private static String generatorConfigPath;

        public static string GeneratorConfigPath
        {
            get
            {
                if (generatorConfigPath == null)
                {
                    generatorConfigPath = InitConfig.getString("BaseInfo", "Generator", @"D:\PumpExperiment\generator.config");
                    generatorConfigPath = generatorConfigPath.Replace("||", "\\");
                }
                return generatorConfigPath;
            }
                
        }


        private static String experimentReportTemplatePath = null;
        public static string ExperimentReportTemplatePath {
            get
            {
                if (experimentReportTemplatePath == null)
                {
                    experimentReportTemplatePath = InitConfig.getString("BaseInfo", "ExperimentReportTemplatePath", @"D:\PumpExperiment");
                    experimentReportTemplatePath = experimentReportTemplatePath.Replace("||", "\\");

                }
                return experimentReportTemplatePath;
            }
        }

        
        private static String experimentReportDir =null;
        public static string ExperimentReportDir {
            get
            {
                if (experimentReportDir == null)
                {
                    experimentReportDir = InitConfig.getString("BaseInfo", "ExperimentReportDir", @"D:\PumpExperiment\ExperimentData");
                    experimentReportDir = experimentReportDir.Replace("||", "\\");

                }
                return experimentReportDir;
            }
        }

        
        private static int dataGetInterval = -1;
        public static int DataGetInterval {
            get
            {
                if (dataGetInterval == -1)
                {
                    string str = InitConfig.getString("BaseInfo", "DataGetInterval", "1000");
                    dataGetInterval = int.Parse(str);

                }
                return dataGetInterval;
            }
        }

        private static int xAxisUnit = -1;

        public static int XAxisUnit {
            get
            {
                if (xAxisUnit == -1)
                {
                    string str = InitConfig.getString("BaseInfo", "XAxisUnit", "5");
                    xAxisUnit = int.Parse(str);

                }
                return xAxisUnit;
            }
        }

        private static int yAxisUnit = -1;

        public static int YAxisUnit {
            get
            {
                if (yAxisUnit == -1)
                {
                    string str = InitConfig.getString("BaseInfo", "YAxisUnit", "5");
                    yAxisUnit = int.Parse(str);

                }
                return yAxisUnit;
            }
        }

        private static double axisMaxRate = Double.NaN;

        public static double AxisMaxRate {
            get
            {
                if (Double.IsNaN(axisMaxRate))
                {
                    string str = InitConfig.getString("BaseInfo", "AxisMaxRate", "0.8");
                    axisMaxRate = double.Parse(str);

                }
                return axisMaxRate;
            }
        }

        private static int drawPointCount = -1;


        public static int DrawPointCount {
            get
            {
                if (drawPointCount == -1)
                {
                    string str = InitConfig.getString("BaseInfo", "DrawPointCount", "30");
                    drawPointCount = int.Parse(str);

                }
                return drawPointCount;
            }
        }

        
    }
}
